import java.io.File;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

import java.util.zip.CheckedInputStream;
import java.util.zip.CRC32;


/**
 * Class used to do concepts test
 * @author Bruno
 */
public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {

//		int i;
//		i = Integer.parseInt("4r");
//		System.out.println(i);
		String path1 = "/home/xfobrol/TestMirror/dir1/file1";
		String path2 = "/home/xfobrol/TestMirror/dir2/file1";
		
		File f1 = new File("/home/xfobrol/TestMirror/test1/file1");
		File f2 = new File("/home/xfobrol/TestMirror/test2/file1");
		
		if (f1.equals(f2))
			System.out.println("f1 EQUALS TO f2");
		else
			System.out.println("f1 DIFFERENT FROM f2");
		
		
		
		FileInputStream file1 = new FileInputStream(path1);
        CheckedInputStream check1 = 
          new CheckedInputStream(file1, new CRC32());
        BufferedInputStream in1 = 
          new BufferedInputStream(check1);
        while (in1.read() != -1) {
            // Read file in completely
        }
        System.out.println("Checksum 1 is " + 
          check1.getChecksum().getValue());

		FileInputStream file2 = new FileInputStream(path2);
        CheckedInputStream check2 = 
            new CheckedInputStream(file2, new CRC32());
          BufferedInputStream in2 = 
            new BufferedInputStream(check2);
          while (in2.read() != -1) {
              // Read file in completely
          }
          System.out.println("Checksum 2 is " + 
            check2.getChecksum().getValue());
        
	}

}
